package cn.njxzc.examples;

class MyThread extends Thread {
	double total;

	public void run() {
		for (int i = 0; i <= 10000000; i++) {
			total = total + i;
		}
		System.out.println("Finished calculating total");
	}
}

public class Exam7_4 {
	public static void main(String[] args) {
		MyThread mt = new MyThread();
		mt.start();
		try {
			mt.join();
		} catch (InterruptedException e) {
			System.out.println(e);
		}
		System.out.println("Total = " + mt.total);
	}
}
